package test.day06;

import java.util.Stack;

public class MyQueueByStack {
	/**
	 * 输入栈
	 */
	private Stack<Integer> a;
	/**
	 * 输出栈
	 */
	private Stack<Integer> b;

	public MyQueueByStack() {
		a = new Stack<>();
		b = new Stack<>();
	}

	public void push(int x) {
		a.push(x);
	}

	public int pop() {
		if (b.isEmpty()) {
			while (!a.isEmpty()) {
				b.push(a.pop());
			}
		}
		return b.pop();
	}

	public int peek() {
		if (b.isEmpty()) {
			while (!a.isEmpty()) {
				b.push(a.pop());
			}
		}
		return b.peek();
	}

	public boolean empty() {
		return a.isEmpty() && b.isEmpty();
	}
}
